import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import datetime
Fitxer agreements abaixat:
pax=pd.read_csv('pax_data_1915_agreements_07-12-21.csv')
print(pax.shape)
pax.head(2)
(1915, 267)
| Con | Contp | PP | PPName | Reg | AgtId | Ver | Agt | Dat | Status | ... | TjRep | TjRSym | TjRMa | TjNR | ImUN | ImOth | ImRef | ImPK | ImE | ImSrc | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Afghanistan | Government/territory | 2 | Afghanistan: 2000s Post-intervention process | Europe and Eurasia | 2232 | 3 | Resolution of Intra Afghan Peace Conference in... | 2019-07-08 | Multiparty signed/agreed | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 1 | Afghanistan | Government | 2 | Afghanistan: 2000s Post-intervention process | Europe and Eurasia | 1739 | 2 | Agreement between the Islamic Republic of Afgh... | 2016-09-22 | Multiparty signed/agreed | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
2 rows × 267 columns
Fitxer corpus agreements abaixat:
paxc=pd.read_csv('pax_corpus_1915_agreements_07-12-21.csv',parse_dates = ["Signed Date"],index_col=["Signed Date"])
print(paxc.shape)
paxc.head(2)
(1915, 13)
| AgreementId | Version | Name | Region | Country | Peace Process | Peace Process Name | Stage | Agreement/Conflict Level | Conflict Nature | Agreement Status | Agreement Text | Interim arrangement | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Signed Date | |||||||||||||
| 2019-07-08 | 2232 | 3 | Resolution of Intra Afghan Peace Conference in... | Europe and Eurasia | Afghanistan | 2 | Afghanistan: 2000s Post-intervention process | Pre | Intra | Government/territory | Multiparty signed/agreed | Unofficial Translation of the Resolution\r\n\r... | No |
| 2016-09-22 | 1739 | 2 | Agreement between the Islamic Republic of Afgh... | Europe and Eurasia | Afghanistan | 2 | Afghanistan: 2000s Post-intervention process | SubPar | Intra | Government | Multiparty signed/agreed | Agreement Between Goira & Hezb-E-Islami Of Afg... | No |
Fitxer amb columnes calculades afegides basat en 'pax_corpus_1915_agreements_07-12-21.csv' (i columnes innecessàries eliminades):
paxc2=pd.read_csv('paxc2.csv',parse_dates = ["Data_de_firma"],index_col=["Data_de_firma"])
print(paxc2.shape)
paxc2.head(2)
(1464, 8)
| AgreementId | Region | Country | DaysInc | 1000/dies_entre_acords | Year | Month | no.d'acords_de_pau_signats | |
|---|---|---|---|---|---|---|---|---|
| Data_de_firma | ||||||||
| 2019-07-08 | 2232 | Europe and Eurasia | Afghanistan | 887.987204 | 1.126142 | 2019 | 7 | 20 |
| 2016-09-22 | 1739 | Europe and Eurasia | Afghanistan | 1019.000000 | 0.981354 | 2016 | 9 | 20 |
paxc2.info()
<class 'pandas.core.frame.DataFrame'> DatetimeIndex: 1464 entries, 2019-07-08 to 2008-07-21 Data columns (total 8 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 AgreementId 1464 non-null int64 1 Region 1464 non-null object 2 Country 1464 non-null object 3 DaysInc 1464 non-null float64 4 1000/dies_entre_acords 1464 non-null float64 5 Year 1464 non-null int64 6 Month 1464 non-null int64 7 no.d'acords_de_pau_signats 1464 non-null int64 dtypes: float64(2), int64(4), object(2) memory usage: 102.9+ KB
Correlació entre les variables:
sns.heatmap(paxc2.corr(), square=True, cmap='RdYlGn', annot=True)
plt.savefig("paxHeatMap.pdf", dpi=300)
plt.show()
Quantitat de tractats de pau per grans regions:
paleta_colors={'Europe and Eurasia':'green', 'Cross-regional':'black',
'Middle East and North Africa':'orange', 'Africa (excl MENA)':'purple',
'Asia and Pacific':'red', 'Americas':'blue'}
# Create count plot with region on the y-axis
sns.countplot(y=paxc2.Region,palette=paleta_colors)
plt.savefig('PaxRegions.pdf',dpi=300)
plt.show()
El coeficient '1000/dies_entre_acords', la inversa dels dies entre successius tractats de pau per a un mateix país, multiplicat per 1000, ens indica la conflictivitat d'un país, i l'hem representat entre els anys 1990 i 2021, on les regions de la database han sigut representades per diferents colors, i la mida de cada punt, representa el nombre de tractats de pau signat pel país en els trenta-un anys: més tractats, més conflicte.
Alguns països conflictius destacats:
mes30=paxc2[paxc2["1000/dies_entre_acords"]>100]
mes30.head()
| AgreementId | Region | Country | DaysInc | 1000/dies_entre_acords | Year | Month | no.d'acords_de_pau_signats | |
|---|---|---|---|---|---|---|---|---|
| Data_de_firma | ||||||||
| 1999-07-13 | 1737 | Middle East and North Africa | Algeria | 7.0 | 142.857143 | 1999 | 7 | 6 |
| 1993-07-28 | 1726 | Europe and Eurasia | Armenia/Azerbaijan/Nagorno-Karabakh | 8.0 | 125.000000 | 1993 | 7 | 22 |
| 1995-01-23 | 1640 | Europe and Eurasia | Bosnia and Herzegovina/Yugoslavia (former) | 8.0 | 125.000000 | 1995 | 1 | 68 |
| 1995-01-02 | 1213 | Europe and Eurasia | Bosnia and Herzegovina/Yugoslavia (former) | 9.0 | 111.111111 | 1995 | 1 | 68 |
| 1994-01-19 | 1298 | Europe and Eurasia | Bosnia and Herzegovina/Yugoslavia (former) | 7.0 | 142.857143 | 1994 | 1 | 68 |
Nombre (relatiu) de tractats de pau d'aquests països:
sns.countplot(y=mes30.Country,hue=mes30.Region, palette=paleta_colors, saturation=1)
plt.savefig('TopNoTractats.pdf', dpi=300)
plt.show()
Evolució de 1000/dies_entre_acords entre 1990 i 2021 acumulant els anys:
def paxsns(paxsegment):
px=sns.relplot(x='Data_de_firma',y='1000/dies_entre_acords',data=paxsegment,kind="scatter",
size="no.d'acords_de_pau_signats",hue="Region",
alpha=0.5,palette={'Europe and Eurasia':'green','Cross-regional':'black',
'Middle East and North Africa':'orange', 'Africa (excl MENA)':'purple',
'Asia and Pacific':'red', 'Americas':'blue'})
px.fig.suptitle('Any: '+str(i))
plt.savefig('Pax_ac'+str(i)+'.pdf',dpi=300)
plt.show()
for i in np.arange(1990,2022):
paxsegment=paxc2[paxc2['Year']<=i]
paxsns(paxsegment)
Evolució de 1000/dies_entre_acords entre 1990 i 2021, any a any:
def paxsns2(paxsegment,any):
px=sns.relplot(x='Data_de_firma',y='1000/dies_entre_acords',data=paxsegment,kind="scatter",
size="no.d'acords_de_pau_signats",hue="Region",
alpha=0.5,palette={'Europe and Eurasia':'green','Cross-regional':'black',
'Middle East and North Africa':'orange', 'Africa (excl MENA)':'purple',
'Asia and Pacific':'red', 'Americas':'blue'})
# plt.annotate("Any: "+str(any), xy=(0,0), xycoords='figure fraction', va='bottom', ha='left')
px.fig.suptitle('Any: '+str(any))
plt.savefig('paxc_anual'+str(any)+'.pdf',dpi=300)
plt.show()
for i in np.arange(1990,2022):
paxsegment=paxc2[paxc2['Year']==i]
paxsns2(paxsegment,i)
Tots els anys:
# paxsns(paxc2)